<template>
  <div style="width: 100%;height: 100%;">
    <div style="padding-bottom: 40px">
    <div class="addren-main">
      <div class="list-itme clearfix"><span>快递公司</span>
        <picker mode="selector" @change="wuliuchange" v-model="wuliuIndex" :range="wuliuNameList" style="width: 75%;float: right">
          <div class="placeholder" style="float: left;width: 90%">
            {{ wuliuName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
      <div class="list-itme clearfix"><span>面单类型</span>
        <picker mode="selector" @change="mobanchange" v-model="mobanIndex" :range="mobanNameList" style="width: 75%;float: right">
          <div class="placeholder" style="float: left;width: 90%">
            {{ mobanName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
      <!--
      <div class="list-itme">
        <span>模板名称</span>
        <input style="width: 75%;float: right" v-model="miandanmoban" type="text" placeholder="请输入10个字符以内" placeholder-class="placeholder"
               placeholder-style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(163,170,183,1);"/>
      </div>-->
      <div class="list-itme clearfix" v-if="shunfengzhilian || shunfengpingduoduo"><span>业务类型</span>
        <picker mode="selector" @change="yewuchange" v-model="yewuIndex" :range="yewuNameList" style="width: 75%;float: right">
          <div class="placeholder" style="float: left;width: 90%">
            {{ yewuName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
      <div class="list-itme clearfix" v-if="shunfengzhilian"><span>付费方式</span>
        <picker mode="selector" @change="fufeichange"  v-model="fufeiIndex"  :range="fufeiNameList"  style="width: 75%;float: right">
          <div class="placeholder" style="float: left;width: 90%">
            {{ fufeiName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
      <div class="list-itme clearfix" v-if="shunfengzhilian && (fufeiIndex == 0 || fufeiIndex == 3)"><span>月结卡号</span>
        <picker mode="selector" @change="kahaochange"  v-model="kahaoIndex" :range="kahaoNamelist"  style="width: 75%;float: right" v-if="kahaoNamelist.length > 0">
          <div class="placeholder" style="float: left;width: 90%">
            {{ kahao }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
        <div v-if="kahaoNamelist.length <= 0" style="width: 75%;float: right">
          <div class="placeholder" @click="addkahao" style="float: left;width: 90%;color: #0077ff">
            添加月结卡号
          </div>
          <div class="add-ren-ft"></div>
        </div>
      </div>
      <div class="list-itme clearfix" v-if="shunfengpingduoduo || qitapingduoduo"><span>拼多多店铺</span>
        <picker mode="selector" @change="dianpuchange"  v-model="dianpuIndex" :range="dianpuNameList"  style="width: 75%;float: right" class="service-item" >
          <div class="placeholder" style="float: left;width: 90%">
            {{ dianpuName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
      <div class="list-itme clearfix" v-if="shunfengpingduoduo || qitapingduoduo"><span>网点</span>
        <picker mode="selector" @change="wangdianchange"  v-model="wangdianIndex" :range="wangdianNameList" style="width: 75%;float: right" class="service-item">
          <div class="placeholder" style="float: left;width: 90%">
            {{ wangdianName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
    </div>
      <div class="addren-main" v-if="shunfengpingduoduo">
        <div class="list-itme ">
          <span>增值服务</span>
        </div>
        <div class="list-itme clearfix">
          <checkbox-group @change="selectbaojia"><checkbox  class="checkbox" :checked="baojia" value="1"/></checkbox-group>
          <span>保价</span>
          <picker mode="selector" v-model="baojiaIndex" @change="baojiaChange" :range="baojiaNameList" class="service-item">
            <div class="placeholder" style="float: left;width: 90%">
              {{ baojiaName }}
            </div>
            <div class="add-ren-ft" >
            </div>
          </picker>
        </div>
        <div class="list-itme clearfix">
          <span>声明价值（元）</span>
          <input  class="service-item"  v-model="shengmingjiage" type="number" placeholder="请输入费用" placeholder-class="placeholder"
                  placeholder-style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(163,170,183,1);"/>
        </div>
      </div>
    <div class="addren-main" v-if="shunfengzhilian">
      <div class="list-itme ">
        <span>增值服务</span>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectziqujian">
          <checkbox  class="checkbox" :checked="ziqujian"  value="1"/></checkbox-group><span>自取件</span>
      </div>
      <!--
      <div class="list-itme clearfix">
        <checkbox-group @change="selectyisuipin"><checkbox  :checked="yisuipin" class="checkbox" value="1"/></checkbox-group>
        <span>易碎品</span>
        <picker mode="selector" @change="yisuichange"  v-model="yisuiIndex" :range="yisuiList"
        class="service-item" >
          <div class="placeholder" style="float: left;width: 90%">
            {{ yisuiName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
      -->
      <div class="list-itme ">
        <checkbox-group @change="selectqiandanfanhuan"><checkbox  class="checkbox" value="1" :checked="qiandanfanhuan" /></checkbox-group>
        <span>签单返还</span>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectchaochangchangzhong"><checkbox  class="checkbox" :checked="chaochangchangzhong"  value="1"/></checkbox-group>
        <span>超长超重费用</span>
        <input  class="service-item"  v-model="chaochangchangzhongValue" type="text" placeholder="请输入费用" placeholder-class="placeholder"
               placeholder-style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(163,170,183,1);"/>
      </div>
      <!-- <div class="list-itme clearfix">
        <checkbox-group @change="selectbiaozhunbaozhang"><checkbox  class="checkbox" :checked="biaozhunbaozhang" value="1"/></checkbox-group>
        <span>标准包装费</span>
        <input class="service-item" type="text" v-model="biaozhunbaozhangValue" placeholder="请输入费用" placeholder-class="placeholder"
               placeholder-style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(163,170,183,1);"/>
      </div> -->
      <div class="list-itme clearfix">
        <checkbox-group @change="selectgexingbaozhang"><checkbox  class="checkbox" :checked="gexingbaozhang" value="1"/></checkbox-group>
        <span>包装服务</span>
        <input class="service-item"  type="text" v-model="gexingbaozhangValue" placeholder="请输入费用" placeholder-class="placeholder"
               placeholder-style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(163,170,183,1);"/>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectdaishoudaikuang"><checkbox  class="checkbox" :checked="daishoudaikuang" value="1"/></checkbox-group>
        <span>代收贷款</span>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectzimujian"><checkbox  class="checkbox" :checked="zimujian" value="1"/></checkbox-group>
        <span>子母件</span>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectbaojia"><checkbox  class="checkbox" :checked="baojia" value="1"/></checkbox-group>
        <span>保价</span>
        <picker mode="selector" v-model="baojiaIndex" @change="baojiaChange" :range="baojiaNameList" class="service-item">
          <div class="placeholder" style="float: left;width: 90%">
            {{ baojiaName }}
          </div>
          <div class="add-ren-ft" >
          </div>
        </picker>
      </div>
      <div class="list-itme clearfix">
        <span>声明价值（元）</span>
        <input  class="service-item"  v-model="shengmingjiage" type="number" placeholder="请输入费用" placeholder-class="placeholder"
                placeholder-style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(163,170,183,1);"/>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectdianziyanshou"><checkbox  class="checkbox" :checked="dianziyanshou" value="1"/></checkbox-group>
        <span>电子验收</span>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectbaoxianfuwu"><checkbox  class="checkbox" :checked="baoxianfuwu" value="1"/></checkbox-group>
        <span>保险服务</span>
      </div>
      <div class="list-itme clearfix">
        <checkbox-group @change="selectkoulingqianshou"><checkbox  class="checkbox" :checked="koulingqianshou" value="1"/></checkbox-group>
        <span>口令签收服务</span>
      </div>
    </div>
    </div>
    <div class="foot" @click="save">保存</div>
    <toast ref="toast"/>
  </div>
</template>

<script>

    import api from '@/utils/api'
    import toast from "@/components/toast";
    import check from "@/utils/check";
    export default {
        components: {toast},

        data() {
            return {
                type: 0, // 0 新增面单，0 修改面单
                sheet : null,  //为空新增，不为空编辑

                shunfengzhilian : false,
                shunfengpingduoduo : false,
                qitapingduoduo : false,

                //物流
                wuliuList: [],
                wuliuName: '请选择',
                wuliuNameList: [],
                wuliuIndex : '',

                //模板
                mobanList: [],
                mobanName: '请选择',
                mobanNameList: [],
                mobanIndex:'',

                //业务
                yewuList : [],
                yewuName : '请选择',
                yewuNameList : [],
                yewuIndex : '',

                //付费
                fufeiList : [{code:1,name:'寄付月结'},{code:2,name:'到付现结'},{code:3,name:'寄付现结'},{code:4,name:'第三方付月结'}] ,
                fufeiName : '请选择',
                fufeiNameList : ['寄付月结','到付现结','寄付现结','第三方付月结'],
                fufeiIndex : '',

                //月结卡号
                kahaolist :[],
                kahaoNamelist : [],
                kahao : '请选择',
                kahaoIndex : '',

                //店铺
                dianpuList:[],
                dianpuName:'请选择',
                dianpuNameList:[],
                dianpuIndex:'',

                //网点
                wangdianList:[],
                wangdianName:'请选择',
                wangdianNameList:[],
                wangdianIndex:'',

                //保价
                baojiaIndex : '',
                baojiaName:'请选择',
                baojiaNameList:["订单金额保价","声明价值保价"],
                baojiaList:[{code:1,name:"订单金额保价"},{code:2,name:"声明价值保价"}],
                shengmingjiage : '', //声明价格

                //易碎
                yisuiList : [1,2,3,4,5,6,7,8,9],
                yisuiName : '请选择',
                yisuiIndex : '',

                miandanmoban : '',
                ziqujian : false,
                yisuipin : false,
                qiandanfanhuan : false,
                chaochangchangzhong : false,
                chaochangchangzhongValue : '',
                biaozhunbaozhang : false,
                biaozhunbaozhangValue : '',
                gexingbaozhang : false,
                gexingbaozhangValue : '',
                daishoudaikuang : false,
                zimujian : false,
                baojia : false,
                dianziyanshou : false,
                baoxianfuwu : false,
                koulingqianshou : false
            }
        },

        onLoad: function (options) {
            this.type = options.type;
            if (this.type == 0) {
                wx.setNavigationBarTitle({
                    title: '新增电子面单'
                })
                this.sheet = null;
            } else {
                wx.setNavigationBarTitle({
                    title: '修改电子面单'
                })
                if(options.sheet){
                    this.sheet = JSON.parse(decodeURIComponent(options.sheet));
                }
            }

          this.inidata();
        },

        onShow(){
            this.shunfengzhilian = false;
            this.shunfengpingduoduo =false;
            this.qitapingduoduo = false;
                //物流
            this.wuliuList=[];
            this.wuliuName= '请选择';
            this.wuliuNameList= [];
            this.wuliuIndex = '';
                //模板
            this.mobanList= [];
            this.mobanName= '请选择';
            this.mobanNameList= [];
            this.mobanIndex='';
                //业务
            this.yewuList = [];
            this.yewuName = '请选择';
            this.yewuNameList = [];
            this.yewuIndex = '';
                //付费
            this.fufeiList = [{code:1,name:'寄付月结'},{code:2,name:'到付现结'},{code:3,name:'寄付现结'},{code:4,name:'第三方付月结'}] ;
            this.fufeiName = '请选择';
            this.fufeiNameList = ['寄付月结','到付现结','寄付现结','第三方付月结'];
            this.fufeiIndex = '';
                //月结卡号
            this.kahaolist =[];
            this.kahaoNamelist = [];
            this.kahao = '请选择';
            this.kahaoIndex = '';
                //店铺
            this.dianpuList=[];
            this.dianpuName='请选择';
            this.dianpuNameList=[];
            this.dianpuIndex='';
                //网点
            this.wangdianList=[];
            this.wangdianName='请选择';
            this.wangdianNameList=[];
            this.wangdianIndex='';
                //保价
            this.baojiaIndex = '';
            this.baojiaName='请选择';
            this.baojiaNameList=["声明价值保价","订单金额保价"];
            this.baojiaList=[{code:1,name:"声明价值保价"},{code:2,name:"订单金额保价"}];
            this.yisuiList = [1,2,3,4,5,6,7,8,9];
            this.yisuiName = '请选择';
            this.yisuiIndex = '';
            this.miandanmoban = '';
            this.ziqujian = false;
            this.yisuipin = false;
            this.qiandanfanhuan = false;
            this.chaochangchangzhong = false;
            this.chaochangchangzhongValue = '';
            this.biaozhunbaozhang = false;
            this.biaozhunbaozhangValue = '';
            this.gexingbaozhang = false;
            this.gexingbaozhangValue = '';
            this. daishoudaikuang = false;
            this.zimujian = false;
            this.baojia = false;
            this.dianziyanshou = false;
            this.baoxianfuwu = false;
            this.koulingqianshou = false;
            this.inidata();
        },
        mounted(){
        },

        methods:{
            selectziqujian(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.ziqujian = true;
                }else{
                    this.ziqujian = false;
                }
            },

            selectyisuipin(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.yisuipin = true;
                }else{
                    this.yisuipin = false;
                    this.yisuiIndex = '';
                    this.yisuiName = '请选择';
                }
            },

            selectqiandanfanhuan(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.qiandanfanhuan = true;
                }else{
                    this.qiandanfanhuan = false;
                }
            },
            selectchaochangchangzhong(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.chaochangchangzhong = true;
                }else{
                    this.chaochangchangzhong = false;
                    this.chaochangchangzhongValue = '';
                }
            },
            selectbiaozhunbaozhang(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.biaozhunbaozhang = true;
                }else{
                    this.biaozhunbaozhang = false;
                    this.biaozhunbaozhangValue = '';
                }
            },
            selectgexingbaozhang(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.gexingbaozhang = true;
                }else{
                    this.gexingbaozhang = false;
                    this.gexingbaozhangValue = '';
                }
            },
            selectdaishoudaikuang(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.daishoudaikuang = true;
                }else{
                    this.daishoudaikuang = false;
                }
            },
            selectzimujian(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.zimujian = true;
                }else{
                    this.zimujian = false;
                }
            },
            selectbaojia(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.baojia = true;
                }else{
                    this.baojia = false;
                    this.baojiaIndex = '';
                    this.baojiaName = '请选择';
                }
            },
            selectdianziyanshou(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.dianziyanshou = true;
                }else{
                    this.dianziyanshou = false;
                }
            },
            selectbaoxianfuwu(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.baoxianfuwu = true;
                }else{
                    this.baoxianfuwu = false;
                }
            },
            selectkoulingqianshou(e){
                var index = e.mp.detail.value;
                if(index && index.length > 0){
                    this.koulingqianshou = true;
                }else{
                    this.koulingqianshou = false;
                }
            },

            initzengzhi(sheetForm){
                this.yisuipin =  sheetForm.userWaybillTemplateAttribute.fragile > 0 ? true : false;
                for(var i in this.yisuiList){
                    if(sheetForm.userWaybillTemplateAttribute.fragile == this.yisuiList[i]){
                        this.yisuiIndex = i;
                        this.yisuiName = this.yisuiList[this.yisuiIndex];
                    }
                }
                this.baojia = sheetForm.userWaybillTemplateAttribute.isInsurance == '1'? true : false;
                for(var i in this.baojiaList){
                    if(sheetForm.userWaybillTemplateAttribute.insuranceType == this.baojiaList[i].code){
                        this.baojiaIndex = i;
                        this.baojiaName = this.baojiaList[this.baojiaIndex].name;
                    }
                    this.shengmingjiage = sheetForm.userWaybillTemplateAttribute.insuranceAmount;
                }
                for(var i in this.fufeiList){
                    if(sheetForm.userWaybillTemplateAttribute.expressPayMethod == this.fufeiList[i].code){
                        this.fufeiIndex = i;
                        this.fufeiName = this.fufeiList[this.fufeiIndex].name;
                    }
                }

                this.ziqujian = sheetForm.userWaybillTemplateAttribute.oneselfPickupFlag == '1' ? true : false;
                this.qiandanfanhuan = sheetForm.userWaybillTemplateAttribute.logisticsReturnFlag== '1' ? true : false;
                this.biaozhunbaozhang = sheetForm.userWaybillTemplateAttribute.packAmount > 0 ? true : false;
                this.biaozhunbaozhangValue = sheetForm.userWaybillTemplateAttribute.packAmount;
                this.daishoudaikuang = sheetForm.userWaybillTemplateAttribute.codFlag == '1' ? true : false;
                this.zimujian = sheetForm.userWaybillTemplateAttribute.expressNumFlag == '1' ? true : false;
                this.gexingbaozhang = sheetForm.userWaybillTemplateAttribute.specialPackAmount > 0 ? true : false;
                this.gexingbaozhangValue = sheetForm.userWaybillTemplateAttribute.specialPackAmount;
                this.dianziyanshou = sheetForm.userWaybillTemplateAttribute.electronicAcceptance == '1' ? true : false;
                this.koulingqianshou = sheetForm.userWaybillTemplateAttribute.iscommandreceive == '1' ? true : false;
                this.baoxianfuwu = sheetForm.userWaybillTemplateAttribute.fresh == '1' ? true : false;
                this.chaochangchangzhongValue = sheetForm.userWaybillTemplateAttribute.ultraHeavyGoodsAmount;
                this.chaochangchangzhong = sheetForm.userWaybillTemplateAttribute.ultraHeavyGoodsAmount > 0 ? true : false;
            },


            inidata(){
                if(this.type == 1 && this.sheet){
                    this.loadwuliu(this.sheet.logisticsCompanyName);
                    this.loadmoban(this.sheet.logisticsCompanyName,this.sheet.waybillTemplateId);
                    this.loadyewuleixing(this.sheet.userWaybillTemplateAttribute.expressType);
                    this.loadPayCust(this.sheet.userWaybillTemplateAttribute.PayCustId);
                    if((this.sheet.logisticsCompanyType == '01' ||  this.sheet.logisticsCompanyType == '-9' ) && ( this.sheet.templateType == '2' ||  this.sheet.templateType == '3')){
                        this.shunfengzhilian = true;
                        this.shunfengpingduoduo = false;
                        this.qitapingduoduo = false;
                        console.log("顺丰直连");
                        this.initzengzhi(this.sheet);
                    }else if((this.sheet.logisticsCompanyType == '01' ||  this.sheet.logisticsCompanyType == '-9' ) && ( this.sheet.templateType == '7')){
                        this.shunfengzhilian = false;
                        this.shunfengpingduoduo = true;
                        this.qitapingduoduo = false;
                        console.log("顺丰拼多多");
                        this.loaddianpu(this.sheet.userWaybillTemplateAttribute.cainiaoShopId,this.sheet.userWaybillTemplateAttribute.cainiaoAddressId);
                        //this.loadwangdian(this.sheet.userWaybillTemplateAttribute.cainiaoShopId,this.sheet.userWaybillTemplateAttribute.cainiaoAddressId);
                    }else {
                        this.shunfengzhilian = false;
                        this.shunfengpingduoduo = false;
                        this.qitapingduoduo = true;
                        console.log("其他拼多多");
                        this.loaddianpu(this.sheet.userWaybillTemplateAttribute.cainiaoShopId, this.sheet.userWaybillTemplateAttribute.cainiaoAddressId);
                        //this.loadwangdian(this.sheet.userWaybillTemplateAttribute.cainiaoShopId,this.sheet.userWaybillTemplateAttribute.cainiaoAddressId);
                    }
                    this.miandanmoban = this.sheet.aliases;
                }else{
                    this.loadwuliu();
                    this.loadmoban();
                    this.loadyewuleixing();
                    this.loadPayCust();
                }
            },

            //物流
            wuliuchange(e) {
                var index = e.mp.detail.value;
                this.wuliuIndex = index;
                this.wuliuName = this.wuliuNameList[index];
                this.loadmoban();
                this.shunfengzhilian = false;
                this.shunfengpingduoduo = false;
                this.qitapingduoduo = false;
            },

            //模板
            mobanchange(e) {
                var _this = this;
                var index = e.mp.detail.value;
                this.mobanIndex = index;
                this.mobanName = this.mobanNameList[index];
                if(  (this.mobanList[this.mobanIndex].logisticsCompanyType == '01' || this.mobanList[this.mobanIndex].logisticsCompanyType == '-9' )
                    && (this.mobanList[this.mobanIndex].templateType == '2' || this.mobanList[this.mobanIndex].templateType == '3')){
                    this.shunfengzhilian = true;
                    this.shunfengpingduoduo = false;
                    this.qitapingduoduo = false;
                    console.log("顺丰直连 "+this.mobanName);
                    if(this.sheet){ //不为空为编辑
                        this.loadyewuleixing(_this.sheet.userWaybillTemplateAttribute.expressType);
                    } else {
                        this.loadyewuleixing();
                    }
                }else if((this.mobanList[this.mobanIndex].logisticsCompanyType == '01' || this.mobanList[this.mobanIndex].logisticsCompanyType == '-9' )
                    && this.mobanList[this.mobanIndex].templateType == '7'){
                    this.shunfengzhilian = false;
                    this.shunfengpingduoduo = true;
                    this.qitapingduoduo = false;
                    console.log("顺丰拼多多 "+this.mobanName);
                    var yewuleixingList =  [
                        {"name":"顺丰标快","value":"1","ext":null},
                        {"name":"顺丰特惠","value":"2","ext":null},
                        {"name":"电商特惠","value":"3","ext":null},
                        {"name":"顺丰次晨","value":"5","ext":null},
                        {"name":"即日件","value":"6","ext":null},
                        {"name":"电商速配","value":"7","ext":null},
                        {"name":"冷运到家","value":"14","ext":null},
                        {"name":"生鲜速配","value":"15","ext":null},
                        {"name":"大闸蟹专递","value":"16","ext":null},
                        {"name":"重货快运","value":"18","ext":null},
                        {"name":"重货专运","value":"153","ext":null},
                        {"name":"小票零担","value":"155","ext":null},
                        {"name":"顺丰微小件","value":"202","ext":null},
                        {"name":"陆运微小件","value":"204","ext":null},
                        {"name":"特惠专配","value":"208","ext":null},
                    ];
                    _this.yewuList = [];
                    _this.yewuNameList = [];
                    _this.yewuIndex = '';
                    _this.yewuName = '请选择';
                    if(yewuleixingList && yewuleixingList.length > 0){
                        for(var i = 0 ; i < yewuleixingList.length ; i ++){
                            var data = yewuleixingList[i];
                            _this.yewuList.push(data);
                            _this.yewuNameList.push(data.name);
                            if(this.sheet){ //不为空为编辑
                                if(data.value == this.sheet.userWaybillTemplateAttribute.expressType){
                                    _this.yewuIndex = i;
                                    _this.yewuName = data.name;
                                }
                            }
                        }
                    }
                }else{
                    this.shunfengzhilian = false;
                    this.shunfengpingduoduo = false;
                    this.qitapingduoduo = true;
                    console.log("其他拼多多 "+this.mobanName);
                }
                this.loaddianpu();
            },

            //店铺
            dianpuchange(e){
                var index = e.mp.detail.value;
                this.dianpuIndex = index;
                this.dianpuName = this.dianpuNameList[index];
                this.loadwangdian();
            },

            //网点
            wangdianchange(e){
                var index = e.mp.detail.value;
                this.wangdianIndex = index;
                this.wangdianName = this.wangdianNameList[index];
            },

            //保价
            baojiaChange(e){
                var index = e.mp.detail.value;
                this.baojiaIndex = index;
                this.baojiaName = this.baojiaNameList[index];
            },

            //易碎
            yisuichange(e){
                var index = e.mp.detail.value;
                this.yisuiIndex = index;
                this.yisuiName = this.yisuiList[index];
            },

            //业务
            yewuchange(e){
                var index = e.mp.detail.value;
                this.yewuIndex = index;
                this.yewuName = this.yewuNameList[index];
            },

            //付费
            fufeichange(e){
                var index = e.mp.detail.value;
                this.fufeiIndex = index;
                this.fufeiName = this.fufeiNameList[index];
            },

            //月结卡号
            kahaochange(e){
                var index = e.mp.detail.value;
                this.kahaoIndex = index;
                this.kahao = this.kahaoNamelist[index];
            },

            loadwuliu(wuliuname) {
                var _this = this;
                wx.request({
                    url: wx.getStorageSync("otherPath") + api.queryAllLogisticsCompanyName + "?ecstoken=" + wx.getStorageSync('sessionId'),
                    method: "POST",
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        ecstoken : wx.getStorageSync('sessionId'),
                        fslb : wx.getStorageSync('fslb')
                    },
                    data: {},
                    success(res) {
                        _this.wuliuList = [];
                        _this.wuliuNameList = [];
                        _this.wuliuName = '请选择';
                        _this.wuliuIndex = '';
                        if(res.data.data && res.data.data.length > 0){
                            for(var i = 0 ; i < res.data.data.length ; i ++){
                                var data = res.data.data[i];
                                _this.wuliuList.push(data);
                                _this.wuliuNameList.push(data.name);
                                if(data.name == wuliuname){
                                    _this.wuliuIndex = i;
                                    _this.wuliuName = data.name;
                                }
                            }
                        }
                    },
                    fail() {
                        _this.$refs.toast.show('网络异常')
                    },
                })
            },

            loadyewuleixing(yewuleixing) {
                var _this = this;
                wx.request({
                    url: wx.getStorageSync("otherPath") + api.queryAllExpressType + "?ecstoken=" + wx.getStorageSync('sessionId'),
                    method: "POST",
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        ecstoken : wx.getStorageSync('sessionId'),
                        fslb : wx.getStorageSync('fslb')
                    },
                    data: {},
                    success(res) {
                        _this.yewuList = [];
                        _this.yewuNameList = [];
                        _this.yewuIndex = '';
                        _this.yewuName = '请选择'
                        if(res.data.data && res.data.data.length > 0){
                            for(var i = 0 ; i < res.data.data.length ; i ++){
                                var data = res.data.data[i];
                                _this.yewuList.push(data);
                                _this.yewuNameList.push(data.name);
                                if(data.value == yewuleixing){
                                    _this.yewuIndex = i;
                                    _this.yewuName = data.name;
                                }
                            }
                        }
                    },
                    fail() {
                        _this.$refs.toast.show('网络异常')
                    },
                })
            },

            loadPayCust(kaohao) {
                var _this = this;
                wx.request({
                    url: wx.getStorageSync("otherPath") + api.queryUserPayCustIdList + "?ecstoken=" + wx.getStorageSync('sessionId'),
                    method: "POST",
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        ecstoken : wx.getStorageSync('sessionId'),
                        fslb : wx.getStorageSync('fslb')
                    },
                    data: {},
                    success(res) {
                        _this.kahaolist = [];
                        _this.kahaoNamelist = [];
                        _this.kahao = '请选择';
                        _this.kahaoIndex = '';
                        if(res.data.data && res.data.data.length > 0){
                            for(var i = 0 ; i < res.data.data.length ; i ++){
                                var data = res.data.data[i];
                                _this.kahaolist.push(data);
                                _this.kahaoNamelist.push(data.name);
                                if(data.id == kaohao){
                                    _this.kahaoIndex = i;
                                    _this.kahao = data.name;
                                }
                            }
                        }
                    },
                    fail() {
                        _this.$refs.toast.show('网络异常')
                    },
                })
            },

            loadmoban(wuliuname,mobanId){
                var _this = this;
                wx.request({
                    url: wx.getStorageSync("otherPath") + api.queryWaybillTemplatesByCompanyName + "?ecstoken=" + wx.getStorageSync('sessionId'),
                    method: "POST",
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        ecstoken : wx.getStorageSync('sessionId'),
                        fslb : wx.getStorageSync('fslb')
                    },
                    data: {
                        logisticsCompanyName: wuliuname ? wuliuname : _this.wuliuName
                    },
                    success(res) {
                        _this.mobanList = [];
                        _this.mobanNameList = [];
                        _this.mobanName = '请选择';
                        _this.mobanIndex = '';
                        if(res.data.data && res.data.data.length > 0){
                          for(var i = 0 ; i < res.data.data.length ; i ++){
                              var data = res.data.data[i];
                              _this.mobanList.push(data);
                              _this.mobanNameList.push(data.aliases);
                              if(data.id == mobanId){
                                  _this.mobanIndex = i;
                                  _this.mobanName = data.aliases;
                              }
                          }
                        }
                    },
                    fail() {
                        _this.$refs.toast.show('网络异常')
                    },
                })
            },

            loaddianpu(dianpuId,wangdianId){
                var _this = this;
                wx.request({
                    url: wx.getStorageSync("otherPath") + api.queryShopByPlatform + "?ecstoken=" + wx.getStorageSync('sessionId'),
                    method: "POST",
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        ecstoken : wx.getStorageSync('sessionId'),
                        fslb : wx.getStorageSync('fslb')
                    },
                    data: {
                        shopPlatform: 16
                    },
                    success(res) {
                        _this.dianpuList = [];
                        _this.dianpuNameList = [];
                        _this.dianpuName = '请选择';
                        _this.dianpuIndex = '';
                        if(res.data.data && res.data.data.length > 0){
                            for(var i = 0 ; i < res.data.data.length ; i ++){
                                var data = res.data.data[i];
                                _this.dianpuList.push(data);
                                _this.dianpuNameList.push(data.shopName);
                                if(data.appKey == dianpuId){
                                    _this.dianpuIndex = i;
                                    _this.dianpuName = data.shopName;
                                }
                            }
                        }
                        if(wangdianId){
                            _this.loadwangdian(wangdianId);
                        }
                    },
                    fail() {
                        _this.$refs.toast.show('网络异常')
                    },
                })
            },

            loadwangdian(wangdianId){
                var _this = this;
                wx.request({
                    url: wx.getStorageSync("otherPath") + api.fetchPddAddress + "?ecstoken=" + wx.getStorageSync('sessionId'),
                    method: "POST",
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        ecstoken : wx.getStorageSync('sessionId'),
                        fslb : wx.getStorageSync('fslb')
                    },
                    data: {
                        oauthId: _this.dianpuList[_this.dianpuIndex].oauthId,
                        logisticsCompanyType : _this.mobanList[_this.mobanIndex].logisticsCompanyType
                    },
                    success(res) {
                        _this.wangdianList = [];
                        _this.wangdianNameList = [];
                        _this.wangdianName = '请选择';
                        _this.wangdianIndex = '';
                        if(res.data.data && res.data.data.length > 0){
                            for(var i = 0 ; i < res.data.data.length ; i ++){
                                var data = res.data.data[i];
                                _this.wangdianList.push(data);
                                _this.wangdianNameList.push(data.name);
                                if(data.value == wangdianId){
                                    _this.wangdianIndex = i;
                                    _this.wangdianName = data.name;
                                }
                            }
                        }
                    },
                    fail() {
                        _this.$refs.toast.show('网络异常')
                    },
                })
            },

            save(){
                var _this = this;
                if(check.isNull(this.wuliuIndex.toString())){
                    this.$refs.toast.show("请选择快递公司");
                    return;
                }
                if(check.isNull(this.mobanIndex.toString())){
                    this.$refs.toast.show("请选择面单类型");
                    return;
                }
                var sheetForm = {};
                if(this.shunfengzhilian){
                    sheetForm.waybillTemplateId = this.mobanList[this.mobanIndex].id;
                    sheetForm.logisticsCompanyType = this.mobanList[this.mobanIndex].logisticsCompanyType;
                    if(check.isNull(this.yewuIndex.toString())){
                        this.$refs.toast.show("请选择业务类型");
                        return;
                    }
                    sheetForm.expressType = this.yewuList[this.yewuIndex].value;
                    if(check.isNull(this.fufeiIndex.toString())){
                        this.$refs.toast.show("请选择付费类型");
                        return;
                    }
                    sheetForm.expressPayMethod = this.fufeiList[this.fufeiIndex].code;
                    if((this.fufeiIndex == 0) || (this.fufeiIndex == 3)){
                        if(check.isNull(this.kahaoIndex.toString())){
                            this.$refs.toast.show("请选择月结卡号");
                            return;
                        }
                        sheetForm.payCustId = this.kahaolist[this.kahaoIndex].name;
                    }
                    /*
                    sheetForm.fragile = this.yisuipin ? 1 : 0;
                    if(this.yisuipin){
                        if(check.isNull(this.yisuiIndex.toString())){
                            this.$refs.toast.show("请选择易碎品数量");
                            return;
                        }
                        sheetForm.fragileValue = this.yisuiList[this.yisuiIndex];
                    }*/
                    sheetForm.oneselfPickupFlag = this.ziqujian ? 1 : 0;
                    sheetForm.logisticsReturnFlag = this.qiandanfanhuan ? 1 : 0;
                    sheetForm.isUltraHeavyGoodsAmount = this.chaochangchangzhong ? 1 : 0;
                    if(this.chaochangchangzhong) {
                        if(check.isNull(this.chaochangchangzhongValue.toString())){
                            this.$refs.toast.show("请输入超长超重金额");
                            return;
                        }
                        sheetForm.ultraHeavyGoodsAmount = this.chaochangchangzhongValue;
                    }
                    sheetForm.isPackAmount = this.biaozhunbaozhang ? 1 : 0;
                    if(this.biaozhunbaozhang) {
                        if(check.isNull(this.biaozhunbaozhangValue.toString())){
                            this.$refs.toast.show("请输入标准包装金额");
                            return;
                        }
                        sheetForm.packAmount = this.biaozhunbaozhangValue;
                    }
                    sheetForm.codFlag = this.daishoudaikuang ? 1 : 0;
                    sheetForm.expressNumFlag = this.zimujian ? 1 : 0;
                    sheetForm.isSpecialPackAmount = this.gexingbaozhang ? 1 : 0;
                    if(this.gexingbaozhang) {
                        if(check.isNull(this.gexingbaozhangValue.toString())){
                            this.$refs.toast.show("请输入个性包装金额");
                            return;
                        }
                        sheetForm.specialPackAmount = this.gexingbaozhangValue;
                    }
                    sheetForm.electronicAcceptance = this.dianziyanshou ? 1 : 0;
                    sheetForm.iscommandreceive = this.koulingqianshou ? 1 : 0;
                    sheetForm.fresh = this.baoxianfuwu ? 1 : 0;

                    sheetForm.isInsurance = this.baojia ? 1 : 0;
                    if(this.baojia) {
                        if(check.isNull(this.baojiaIndex.toString())){
                            this.$refs.toast.show("请选择保价类型");
                            return;
                        }
                        sheetForm.insuranceType = this.baojiaList[this.baojiaIndex].code;

                        if(sheetForm.insuranceType == 1 && check.isNull(this.shengmingjiage.toString())){
                            this.$refs.toast.show("请输入声明价值");
                            return;
                        }
                        sheetForm.insuranceAmount = this.shengmingjiage;
                    }
                    sheetForm.isAccountNumberOauth = 0;
                    sheetForm.printDeliveryFlag = 0;
                    sheetForm.hasAttrbuite = true;
                }else if(this.shunfengpingduoduo){
                    if(check.isNull(this.yewuIndex.toString())){
                        this.$refs.toast.show("请选择业务类型");
                        return;
                    }
                    if(check.isNull(this.dianpuIndex.toString())){
                        this.$refs.toast.show("请选择拼多多店铺");
                        return;
                    }
                    if(check.isNull(this.wangdianIndex.toString())){
                        this.$refs.toast.show("请选择网点");
                        return;
                    }
                    sheetForm.isInsurance = this.baojia ? 1 : 0;
                    if(this.baojia) {
                        if(check.isNull(this.baojiaIndex.toString())){
                            this.$refs.toast.show("请选择保价类型");
                            return;
                        }
                        sheetForm.insuranceType = this.baojiaList[this.baojiaIndex].code;
                        if(sheetForm.insuranceType == 1 && check.isNull(this.shengmingjiage.toString())){
                            this.$refs.toast.show("请输入声明价值");
                            return;
                        }
                        sheetForm.insuranceAmount = this.shengmingjiage;
                    }
                    sheetForm.waybillTemplateId = this.mobanList[this.mobanIndex].id;
                    sheetForm.expressType = this.yewuList[this.yewuIndex].value;
                    sheetForm.cainiaoShopId = this.dianpuList[this.dianpuIndex].oauthId;
                    sheetForm.cainiaoAddressId = this.wangdianList[this.wangdianIndex].value;
                    sheetForm.isAccountNumberOauth = 0;
                    sheetForm.hasAttrbuite = true;
                }else if(this.qitapingduoduo){
                    if(check.isNull(this.dianpuIndex.toString())){
                        this.$refs.toast.show("请选择拼多多店铺");
                        return;
                    }
                    if(check.isNull(this.wangdianIndex.toString())){
                        this.$refs.toast.show("请选择网点");
                        return;
                    }
                    sheetForm.waybillTemplateId = this.mobanList[this.mobanIndex].id;
                    sheetForm.cainiaoShopId = this.dianpuList[this.dianpuIndex].oauthId;
                    sheetForm.cainiaoAddressId = this.wangdianList[this.wangdianIndex].value;
                    sheetForm.isAccountNumberOauth = 0;
                    sheetForm.hasAttrbuite = true;
                }
                var url = '';
                if (this.sheet && this.sheet.id) {
                    url = api.modifyUserWaybillTemplateAttr;
                    sheetForm.userWaybillTemplateId = this.sheet.id;
                } else {
                    url = api.addUserWaybillTemplateWithAttr;
                }
                wx.request({
                    url: wx.getStorageSync("otherPath") + url + "?ecstoken=" + wx.getStorageSync('sessionId'),
                    method: "POST",
                    header: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        ecstoken : wx.getStorageSync('sessionId'),
                        fslb : wx.getStorageSync('fslb')
                    },
                    data: sheetForm,
                    success(res) {
                        if(res.data.code != 200){
                            _this.$refs.toast.show(res.data.msg);
                            return ;
                        }
                        _this.$refs.toast.show('保存成功')
                        setTimeout(function () {
                            wx.navigateBack({
                                delta: 1
                            })
                        },1500)
                    },
                    fail() {
                        _this.$refs.toast.show('网络异常')
                    },
                })
            },
            addkahao(){
                var url = "../kahao/main?";
                mpvue.navigateTo({url});
            },
        },
    }
</script>

<style lang="wxss">
  page {
    width: 100%;
    height: 100%;
    background-color: #F7FBFF;
  }
  checkbox .wx-checkbox-input {
  width: 28rpx;
  height: 28rpx;
  border: 4rpx solid #A3AAB7;
  border-radius: 100%;
}
/*复选框外框选中样式*/
checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  border-color: #0077ff;
  background-color: #0077ff;
}
/*复选框选中后内部样式*/
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
  content: "\00a0";
  display: inline-block;
  border: 4rpx solid #fff;
  border-top-width: 0;
  border-right-width: 0;
  width: 18rpx;
  height: 10rpx;
  transform: rotate(-50deg);
  position: absolute;
  top: 8rpx;
  left: 6rpx;
}
</style>

<style scoped>
  .clearfix::after{
      display: block;
      content: "";
      clear:both;
  }
  .addren-main {
    padding-right: 10px;
    padding-left: 10px;
    background-color: #FFFFFF;
    margin-bottom: 10px;
  }

  .list-itme {
    position: relative;
    /* height: 40px; */
    line-height: 40px;
    background-color: #FFFFFF;
    border-bottom: 0.5px solid #E8EAF0;
  }

  .list-itme span {
    padding-left: 10px;
    font-size: 13px;
    font-family: PingFang-SC-Medium;
    font-weight: 500;
    color: #373E4F;
  }


  .placeholder {
    font-family: PingFang SC;
    font-size: 26rpx;
    color: #333;
  }

  .item-placeholder {
    font-family: PingFang-SC-Medium;
  }
    /* 向右箭头 */
  .add-ren-ft {
    display: inline-block;
  position: absolute;
  right: 0.1rem;
  top: calc(50% - 0.04rem);
  height: 0.16rem;
  width: 0.16rem;
  border-width: 2px 2px 0 0;
  border-color: #A3AAB7;
  border-style: solid;
  -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
  transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
  }

  .caozuo {
    height: 30px;
    line-height: 30px;
  }

  .caozuo a {
    height: 30px;
    float: right;
    font-size: 12px;
    font-family: PingFang SC;
    font-weight: 500;
    color: rgba(0, 119, 255, 1);
    margin-right: 8px;
  }

  .foot {
    text-align: center;
    vertical-align: middle;
    width: 100%;
    height: 40px;
    position: fixed;
    bottom: 0;
    background-color: #0077FF;
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: 500;
    color: rgba(255, 255, 255, 1);
    line-height: 40px;
  }

  .checkbox {
    /* transform: scale(0.5); */
    float: left;
    margin-left: 15rpx;
    /* margin-left: -0.12rem; */
  }

  /* 输入框 */

  .list-itme input {
    width: 75%;
    float: right;
    margin-top: 10px;
  }
  .list-itme .service-item{
    width:60%;
    float:right;
  }

</style>
